#ifndef __CORE_H_
#define __CORE_H_

#include "input_judge.h"
#include "list.h"
#include "login.h"
#include "progress_bar.h"
#include "train_ticket.h"


#define  CORE_BLACK         "\033[30m"
#define  CORE_RED           "\033[31m"
#define  CORE_GREEN         "\033[32m"
#define  CORE_YELLOW        "\033[33m"
#define  CORE_BLUE          "\033[34m"
#define  CORE_WHITE         "\033[37m"
#define  CORE_NONE          "\033[0m"
#define  CLEAN_LINE         "\033[K"
#define  REVERSE_SHOW       "\033[7m"
#define  HIGH_LIGHT         "\033[?25h"
#define  LOW_LIGHT          "\033[?25l"


#define CLEAR()         printf("\033[2J")           /*清除屏幕*/
#define MOVEUP(x)       printf("\033[%dA", (x))     /*上移光标*/
#define MOVEDOWN(x)     printf("\033[%dB", (x))     /*下移光标*/
#define MOVELEFT(y)     printf("\033[%dD", (y))     /*左移光标*/
#define MOVERIGHT(y)    printf("\033[%dC",(y))      /*右移光标*/
#define MOVETO(x,y)     printf("\033[%d;%dH", (x), (y))     /*定位光标*/
#define RESET_CURSOR()  printf("\033[H")            /*光标复位*/
#define HIDE_CURSOR()   printf("\033[?25l")         /*隐藏光标*/
#define SHOW_CURSOR()   printf("\033[?25h")         /*显示光标*/
#define HIGHT_LIGHT()   printf("\033[7m")         
#define UN_HIGHT_LIGHT() printf("\033[27m")

#define MENU_NUM        (10)
#define OPTION_MAX      (10)


struct option {
    int option_type;
    int x_position;
    int y_position;
    char name[20];
    char *p_data;
    int data_length;
};

struct menu {
    int option_number;
    int current_option;
    char title[20];
    char temp[20];
    struct option option[OPTION_MAX];
};

struct core {
    struct list_head ticket_head;
    struct list_head booked_ticket_id_head;
    struct login_info login_info_data;
    struct user_info user_info_data;
    struct menu menu_data[MENU_NUM];
};

enum menu_options {
    LOGIN_MENU = 0,         /*登录界面*/
    REGISTER_MENU,          /*注册界面*/
    ADD_USER_INFO_MENU,     /*完善用户信息界面*/
    MAIN_MENU,              /*主界面*/
    USER_INFO_MENU,          /*个人信息界面*/
    BOOK_RETURN_TICKET,
    SYSTEM_EXIT_MENU,       /*退出界面*/
    GO_BACK_MENU,           /*返回上一个界面*/
    SYSTEM_EXIT             /*用来表示从退出界面退出*/
};

enum option_type {
    HAVE_DATA = 0,
    NO_DATA
};

enum {
    CORE_PARAM_NULL = 1
};

typedef int (*menu_func_t)(struct core *);

extern struct core *init(menu_func_t *p_menu_func);
extern int run(struct core *p_core, menu_func_t *p_menu_func);
extern int destroy(struct core *p_core, menu_func_t *p_menu_func);

#endif